const app = getApp()
Page({
  data: {
    arry: [],
  },
  onLoad: function () {
    var that = this;
  console.log("日志登陆")
    wx.login({
      success: function (res) {
        var code = res.code
        //console.log(code)
        //发送请求
        wx.request({
          url: 'https://zouzou.work/zz/demo.php', //接口地址
          data: {
            code: code,
          },
          method: 'GET',
          header: {
            'content-type': 'application/json' //默认值
          },
          success: function (res) {
    
    //得到openid

          var openid = res.data.openid
         // console.log('openid是：' + openid)
            wx.request({
              url: 'https://zouzou.work/zz/wxdb_return.php',
              data: {
                openid: openid
              },

              method: 'POST',

              header: { 'content-type': 'application/x-www-form-urlencoded' 
       
                },

              success: function (res) {
                console.log(res.data),
                  that.setData({ arry: res.data, })
              }
            })
      }
    })
      },
    })
  },

   onShow:function() { 
    this.onLoad()
     console.log('页面显示')
   },


  delMemo:function(e){
          //删除数据库内容
          var value = e.target.dataset.value
          var dated = e.target.dataset.dated
          console.log(value)
          console.log(dated)
          var that = this;

          wx.request({
            url: 'https://zouzou.work/zz/wxdb_deldata.php',
            data: { value: value ,
              dated:dated
            },
            method: 'POST',
            header: { "content-type": "application/x-www-form-urlencoded" },
            success: function (res) {
             console.log(res.data)
              wx.showToast({
                title: '删除成功！',
                icon: 'error',
                duration: 1000
              })
              that.onLoad()
            }
          })

  }
})

  
